#!"/Applications/XAMPP/xamppfiles/bin/perl"

package User;
use Data::Dumper;
#use lib "/System/Library/Perl/Extras/5.12/darwin-thread-multi-2level/";

#use Digest::SHA1;

sub new
{
    my $class = shift;
    my $self = {
    	_id => undef,
        _username => shift,
#        _password => sha1(shift),
        _password => shift,
        _address  => shift,
        _phone    => shift,
        _ordersAddress=> shift
    };
    bless $self, $class;
    return $self;
}

sub createFromDatabase
{
	my ($self, %usrHash) = @_;
	while (my $hash_ref = %usrHash) {
        print $hash_ref->{username}, " is ", $hash_ref->{phone}, 
              " years old, and has a " , $hash_ref->{address}, "\n";
    }
}

sub setId
{
	my ( $self, $id ) = @_;
    $self->{_id} = $id if defined($id);
    return $self->{_id};
}

sub getId
{
	my ($self) = @_;
	return $self->{_id};
}

sub getUsername {
    my( $self ) = @_;
    return $self->{_username};
}

sub getPassword
{
	my($self) = @_;
	return $self->{_password};
}
sub getAddress {
    my( $self ) = @_;
    return $self->{_address};
}

sub getPhone {
    my( $self ) = @_;
    return $self->{_phone};
}

sub setOrderAddress {
    my ( $self, $orderAddress ) = @_;
    $self->{_orderAddress} = $orderAddress if defined($orderAddress);
    return $self->{_orderAddress};
}

sub getOrderAddress {
    my( $self ) = @_;
    return $self->{_ordersAddress};
}

1;